/*
 * CBadPhysics.h
 *
 *  Created on: 07.01.2012
 *      Author: Kirill Blinov
 *      Copyright: LGPL
 */

#ifndef CBADPHYSICS_H_
#define CBADPHYSICS_H_

#include "BasicTypes.h"
#include "Constants.h"
#include <btBulletDynamicsCommon.h>
#include "glm/gtx/quaternion.hpp"
#include <time.h>

class CBadPhysics
{
private:
	btDiscreteDynamicsWorld         *dynamicsWorld;
	btDefaultCollisionConfiguration *collisionCfg;
	btAxisSweep3                    *axisSweep;
	std::vector<btRigidBody*>        Objects;
	clock_t                          lastTime;
public:
	CBadPhysics();
	virtual ~CBadPhysics();

	UINT      AddRigidObject( const float Mass, glm::quat  Orientation, glm::vec3 Position,
			                  const glm::vec3 Dimension, const glm::vec3 Inertia );
	glm::mat4 GetObjectMatrix( const UINT ObjectID );
	glm::quat GetOrientation( const UINT ObjectID );
	void      Simulate();
	std::vector<glm::vec3> GetContactPoints();
	void      MoveRotate( const UINT ObjectID, const glm::vec3 Translation, const glm::quat *Rotation = NULL );
	void      ApplyForce( const UINT ObjectID, const glm::vec3 Force );
	void      ApplyForce( const UINT ObjectID, const glm::vec3 Force, const glm::vec3 Point );
	void      ApplyImpulse( const UINT ObjectID, const glm::vec3 Impulse );
	void      ApplyImpulse( const UINT ObjectID, const glm::vec3 Impulse, const glm::vec3 Point );
	void      ApplyVelocity( const UINT ObjectID, const glm::vec3 Velocity );
	void      ApplyTorque( const UINT ObjectID, const glm::vec3 Torque );
	void      AddPlane( const glm::vec3 Normal, const float PlaneConstant );
};

#endif /* CBADPHYSICS_H_ */
